#read in oil spill data
oil_spill <- read_sf(here("Oil_Spill_Incident_Tracking-shp"), layer = "Oil_Spill_Incident_Tracking") %>% 
  clean_names() %>% 
  rename(county = localecoun)

#check the refrence system
#st_crs(oil_spill)

#read in ca county boundaries
ca_county <- read_sf(here("ca_shape"), layer = "CA_Counties_TIGER2016"
) %>% 
  clean_names()

#st_crs(ca_county)

#transform to match
ca_county <- st_transform(ca_county, st_crs(oil_spill))

California Oil Spills: 2008

Let’s look at the California oilspills recorded in 2008. These spills include inland and marine oil spills. Each red do represents a recorded oil spill.

tmap_mode("view")

#tm_shape(oil_spill) +
  #tm_dots("county")

tm_shape(ca_county) +
  tm_fill("name", palette = "YlOrBr", show.legend = FALSE) +
  tm_shape(oil_spill) +
  tm_dots(aes(color = "darkred")) 

Inland Oil Spills: 2008

Now let’s look at just inland oil spills per county in 2008. Los Angeles County had the most recorded oil spills, with over twice as many recorded events than any other county. Los Angeles had 370 events, while the next closest, San Mateo County, had 173 events.

#looking at inland spills counts per county
inland <- oil_spill %>% 
  filter(inlandmari == "Inland")

ca_inland <- ca_county %>% 
  st_join(inland)

inland_spill <- ca_inland %>% 
  count(county)
 

ggplot(data = inland_spill) +
  geom_sf(aes(fill = n), color = "white", size = 0.1) +
  scale_fill_gradientn(colors = c("lightgray","darkorange","darkred")) +
  theme_minimal() +
  labs(fill = "Number of Oil Spills per County",
       title = "2008 Inland California Oil Spills")